import request from '@/utils/request';

// 新增客户端
export function addClient(flClient) {
  return request({
    url: '/flclient/add',
    method: 'post',
    data: flClient
  });
}

// 删除客户端
export function deleteClient(clientId) {
  return request({
    url: `/flclient/delete/${clientId}`,
    method: 'delete'
  });
}

// 更新客户端信息
export function updateClient(flClient) {
  return request({
    url: '/flclient/update',
    method: 'post',
    data: flClient
  });
}

// 根据ID和任务ID查询客户端
export function getClientByClientIdAndTaskId(clientId, taskid) {
  return request({
    url: '/flclient/selectByClientIdAndTaskId',
    method: 'get',
    params: { clientId, taskid }
  });
}
export function getTaskId(taskid) {
  return request({
    url: '/flclient/selectAllClientIdsByTaskId',
    method: 'get',
    params: { taskid }
  });
}

// 查询所有客户端
export function getAllClients(flClient) {
  return request({
    url: '/flclient/selectAll',
    method: 'get',
    params: flClient
  });
}

// 分页查询客户端
export function getClientsByPage(flClient, pageNum = 1, pageSize = 10) {
  return request({
    url: '/flclient/selectPage',
    method: 'get',
    params: {
      ...flClient,
      pageNum,
      pageSize
    }
  });
}

// 更新客户端参与的任务
export function updateClientTasks(clientTaskRequest) {
  return request({
    url: '/flclient/updateTasks',
    method: 'post',
    data: clientTaskRequest
  });
}